All Questions
41 questions
3votes
2answers
158views
Factor 999999 numbers as fast as possible
My code finds the prime factorization of numbers, ordering the prime numbers from least to greatest. It prints a list of 999999 prime factorizations (which can be changed if you edit the function call ...
1vote
2answers
155views
Improving Project Euler code problem #10
So, I just finished Problem 10 on Project Euler, but it took about 3 to 4 minutes for my output to come out, due to bad coding, I guess, any suggestions on how could I optimize my code? Question The ...
7votes
2answers
2kviews
Arranging numbers in a circle such that the sums of neighbors and sums of diametric opposites are prime
I need to create a circle with numbers from 1 to n , however it is necessary to respect some rules: All numbers from 1 to n are used in the circle only once. The sum of two consecutive numbers ...
6votes
2answers
260views
Goldbach conjecture solution finder
The Goldbach conjecture says: any even number greater than two can be represented by the sum of two prime numbers. G(n) = { (p1, p2) | p1 + p2 = n, p1 and p2 are prime numbers with p1 < p2 } For ...
2votes
1answer
1kviews
Finding the first 10 million primes
I'm trying to find the first 100 million primes and am trying to find the most efficient way to do it. Can I get some advice on how I could improve this? ...
0votes
1answer
361views
Finding prime numbers performance
I am writing an app that finds prime numbers within a specified range. Currently i am updating almost every part of the app and i have also changed the way i find prime numbers. The problem is that ...
97votes
5answers
19kviews
Load fifty million integers as quickly as possible in Java
I am working my way through Project Euler. Many of the problems deal with prime number calculations: this is the type of code that can be extracted into a separate class and reused. While calculating ...
3votes
3answers
609views
First n primes optimization
Pretty standard. Generates the first n primes, input via a scanner. ...
6votes
2answers
2kviews
Find prime positioned prime number
This is a question from programming contest. This contest is already over. Now, all the prime numbers are arranged sequentially in ascending order. i.e:- 2, 3, 5,7...and so on. Now, your task is to ...
2votes
1answer
157views
Yet another Sieve of Eratosthenes in Java
I wanted a reusable class for generating a list of primes till some arbitrary (but reasonable) limit. So, I wrote a class Primes that implements the Sieve of ...
2votes
2answers
339views
Finding all the prime factors of a number
I want to calculate all the prime factors of a number in the range 2 ≤ N ≤ 107. Here is my function: ...
4votes
1answer
398views
Sieve of Eratosthenes Primes Efficiency
I'm fairly new to Java and was trying to make a program that's generates the primes from 2 - 100. I originally had a design of my own making but it was fairly inefficient so I did some research and ...
5votes
2answers
944views
Find the next prime number — flow control of nested `for` loops
This code works perfectly, but it bothers me. Having a labeled, nested for loop, with a true condition, a ...
4votes
1answer
695views
Calculating the nth prime number for huge BigIntegers
I wrote this simple class for calculating the nth prime: ...
4votes
2answers
2kviews
Find the highest occurring digit in the prime numbers present between L and R (both inclusive)
Given two numbers L and R, find the highest occurring digit in the prime numbers present between L and R (both inclusive). If multiple digits have the same highest frequency print the largest of ...